import { DataTypes, Model } from 'sequelize'
import { sequelize } from '../../connect'
import { findAllValues, findOneRandomValue, findOneValue } from '../../public'

type ModelProps = {
  id: number
  race_name: string // 种族名
  affixes: string // 词条

  // 八项属性基础
  constitution_base: number // 体质基础
  spirit_base: number // 精神基础
  strength_base: number // 力量基础
  intelligence_base: number // 智力基础
  agility_base: number // 敏捷基础
  perception_base: number // 感知基础
  charm_base: number // 魅力基础
  luck_base: number // 幸运基础

  // 八项成长字段
  constitution_growth: number // 体质成长
  spirit_growth: number // 精神成长
  strength_growth: number // 力量成长
  intelligence_growth: number // 智力成长
  agility_growth: number // 敏捷成长
  perception_growth: number // 感知成长
  charm_growth: number // 魅力成长
  luck_growth: number // 幸运成长

  // 物理精通
  stab_mastery: number
  slash_mastery: number
  strike_mastery: number

  // 物理抗性
  stab_resist: number
  slash_resist: number
  strike_resist: number

  // 元素精通
  metal_mastery: number
  wood_mastery: number
  water_mastery: number
  fire_mastery: number
  earth_mastery: number
  ice_mastery: number
  thunder_mastery: number
  wind_mastery: number
  light_mastery: number
  dark_mastery: number

  // 元素抗性
  metal_resist: number
  wood_resist: number
  water_resist: number
  fire_resist: number
  earth_resist: number
  ice_resist: number
  thunder_resist: number
  wind_resist: number
  light_resist: number
  dark_resist: number
}

class race_extra extends Model<ModelProps> {
  public static findAllValues = findAllValues
  public static findOneValue = findOneValue
  public static findOneRandomValue = findOneRandomValue
}

race_extra.init(
  {
    id: {
      type: DataTypes.BIGINT,
      primaryKey: true,
      allowNull: false,
      autoIncrement: true,
      comment: '自增主键'
    },
    race_name: {
      type: DataTypes.STRING(50),
      allowNull: false,
      comment: '种族名'
    },
    affixes: {
      type: DataTypes.STRING(50),
      allowNull: false,
      comment: '词条'
    },
    constitution_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '体质基础'
    },
    spirit_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '精神基础'
    },
    strength_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '力量基础'
    },
    intelligence_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '智力基础'
    },
    agility_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '敏捷基础'
    },
    perception_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '感知基础'
    },
    charm_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '魅力基础'
    },
    luck_base: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '幸运基础'
    },
    constitution_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '体质成长'
    },
    spirit_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '精神成长'
    },
    strength_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '力量成长'
    },
    intelligence_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '智力成长'
    },
    agility_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '敏捷成长'
    },
    perception_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '感知成长'
    },
    charm_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '魅力成长'
    },
    luck_growth: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '幸运成长'
    },
    // 物理精通
    stab_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '刺击精通'
    },
    slash_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '斩击精通'
    },
    strike_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '打击精通'
    },
    // 物理抗性
    stab_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '刺击抗性'
    },
    slash_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '斩击抗性'
    },
    strike_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '打击抗性'
    },
    // 元素精通
    metal_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '金元素精通'
    },
    wood_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '木元素精通'
    },
    water_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '水元素精通'
    },
    fire_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '火元素精通'
    },
    earth_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '土元素精通'
    },
    ice_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '冰元素精通'
    },
    thunder_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '雷元素精通'
    },
    wind_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '风元素精通'
    },
    light_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '光元素精通'
    },
    dark_mastery: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '暗元素精通'
    },
    // 元素抗性
    metal_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '金元素抗性'
    },
    wood_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '木元素抗性'
    },
    water_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '水元素抗性'
    },
    fire_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '火元素抗性'
    },
    earth_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '土元素抗性'
    },
    ice_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '冰元素抗性'
    },
    thunder_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '雷元素抗性'
    },
    wind_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '风元素抗性'
    },
    light_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '光元素抗性'
    },
    dark_resist: {
      type: DataTypes.FLOAT,
      allowNull: false,
      defaultValue: 0,
      comment: '暗元素抗性'
    }
  },
  {
    sequelize,
    tableName: 'race_extra',
    freezeTableName: true,
    createdAt: false,
    updatedAt: false,
    indexes: [
      {
        unique: true,
        fields: ['id']
      }
    ]
  }
)

export { race_extra }
